package org.cx.oa.web.struts.actions;

import javax.mail.Message;

import javax.mail.Part;
import javax.mail.internet.MimeMessage;

import org.cx.oa.entity.MailClient;
import org.cx.oa.entity.mess;
import org.cx.oa.util.conUtil;
import org.cx.oa.util.mailUtil;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;


public class messageAction extends ActionSupport {
	private mess m;

	public mess getM() {
		return m;
	}

	public void setM(mess m) {
		this.m = m;
	}

	public String execute(){
		System.out.println(m.getIndex()+"------------------");
		MailClient client=(MailClient)ActionContext.getContext().getSession().get("mailuser" );
		try {
			int i=Integer.valueOf(m.getIndex());
			  Message message[] = conUtil.connecte(client.getUser(), client.getPass());
			   mailUtil  messageInfo = new mailUtil((MimeMessage)message[i]);
			   messageInfo.getMailContent((Part)message[i]);
			   ActionContext.getContext().getSession().put("messageInfo", messageInfo);
			  
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return SUCCESS;
	}

}
